package com.szwistar.common.meta;

import com.j256.ormlite.field.DatabaseField;
import com.szwistar.common.meta.DefField;
import com.szwistar.common.meta.DefObject;

/**
 * 如果要让 JsonMapper.fromJson(params, typeClazz) 能够识别字段，则需要至少以下3种方式之一：
 * <li>字段标识为 public
 * <li>字段有 getter 函数
 * <li>字段有 setter 函数
 */

@DefObject(typeId = 123, title = "示例配置参数", description = "演示配置工作模式等参数")
public class DemoConfig {
    @DatabaseField(generatedId = true, canBeNull = false, uniqueIndex = true)
    Integer id;

    //@DefField(title="制式", uiType="strings", rangeJson="[\"GSM\",\"UMTS\",\"LTE\"]")
    //@DefField(title="制式", uiType="strings", rangeJs="['GSM','UMTS','LTE']")
    @DefField(title = "制式", uiType = "strings", rangeJs = "ota.getRadioModes()")
    @DatabaseField
    String radioMode;

    //{"Band 1":123,"Band 2":345,"Band 3":456}
    @DefField(title = "频段", uiType = "list", rangeJs = "ota.getBands(me.radioMode)")
    @DatabaseField
    int bandId;

    // 关于字段联动实现机制
    @DefField(title = "下行频率", uiType = "number", enable = "me.bandId==12 || me.bandId==13")
    @DatabaseField
    int dlFreq;

    @DefField(title = "上行频率", uiType = "number", enable = "me.bandId!=12 && me.bandId!=13")
    @DatabaseField
    int ulFreq;

    @DefField(title = "中心频率", uiType = "number", enable = "me.bandId!=12 && me.bandId!=13")
    @DatabaseField
    int middleFreq = -1;

    public Integer getId() { return id; }
    public String getRadioMode() { return radioMode; }
    public int getBandId() { return bandId; }
    public int getDlFreq() { return dlFreq; }
    public int getUlFreq() { return ulFreq; }
    public int getMiddleFreq() { return middleFreq; }
}
